import React from 'react';
import styled from 'styled-components';
import { useGame } from '../context/GameContext';

const PauseOverlay = styled.div`
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 20px;
  z-index: 100;
`;

const PauseText = styled.h2`
  color: white;
  font-size: 2rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
`;

const Button = styled.button`
  padding: 10px 20px;
  font-size: 1.1rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background-color: #ff1493;
  color: white;
  transition: all 0.3s ease;

  &:hover {
    transform: scale(1.05);
    background-color: #ff69b4;
  }
`;

const Instructions = styled.div`
  color: white;
  text-align: center;
  margin-top: 20px;

  p {
    margin: 5px 0;
    font-size: 1.1rem;
  }
`;

const PauseMenu: React.FC = () => {
  const { dispatch } = useGame();

  const handleResume = () => {
    dispatch({ type: 'SET_STATE', payload: 'playing' });
  };

  const handleRestart = () => {
    dispatch({ type: 'RESET_GAME' });
    dispatch({ type: 'SET_STATE', payload: 'start' });
  };

  return (
    <PauseOverlay>
      <PauseText>游戏暂停</PauseText>
      <Button onClick={handleResume}>继续游戏</Button>
      <Button onClick={handleRestart}>重新开始</Button>
      <Instructions>
        <p>按 P 继续游戏</p>
        <p>按 R 重新开始</p>
      </Instructions>
    </PauseOverlay>
  );
};

export default PauseMenu; 